/*
 * @Author: Turump 
 * @Date: 2021-03-26 15:26:12 
 * @Last Modified by: Turump
 * @Last Modified time: 2021-03-26 18:05:07
 */

/**
 * shader动画时间推进器
 */

const { ccclass, property } = cc._decorator;

@ccclass
export default class ShaderTimer extends cc.Component {

    step = 0.01
    total = 0;
    material: cc.Material = null;

    onLoad() {
        let spr = this.node.getComponent(cc.Sprite)
        this.material = spr.getMaterial(0)
    }

    update() {
        if (this.total >= 1) {
            this.node.destroy();
            return;
        }
        this.total += this.step;
        this.material.setProperty("time", this.total);
    }

}
